package com.bstek.urule.springboot.action.inner;

import com.bstek.urule.model.library.action.annotation.ActionBean;
import com.bstek.urule.model.library.action.annotation.ActionMethod;
import com.bstek.urule.model.library.action.annotation.ActionMethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;

@Component
@ActionBean(name="List集合-扩展")
public class ListAction {
    @ActionMethod(name="使用分隔符，转为字符串")
    @ActionMethodParameter(names={"目标集合", "分隔符"})
    public String join(List<String> list, String split){
        if(CollectionUtils.isEmpty(list)){
            return "";
        }
        return list.stream().collect(Collectors.joining(split));
    }
}
